﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AspNet.Identity.DataAccess;
using Microsoft.AspNet.Identity;

namespace MvcApplication.Cms
{
    public static class SaleSystemConfig
    {
        public static void InitializeDatabase()
        {
            var roleManager = new RoleManager<IdentityRole, Guid>(new RoleStore());

            #region 创建管理员角色
            var managerRoleName = "SaleManager";
            var managerRole = roleManager.FindByName(managerRoleName);

            if (managerRole == null)
            {
                managerRole = new IdentityRole(managerRoleName);
                roleManager.Create(managerRole);
            }
            #endregion

            #region 创建销售着角色
            var saleRoleName = "Sale";
            var saleRole = roleManager.FindByName(saleRoleName);

            if (saleRole == null)
            {
                saleRole = new IdentityRole(saleRoleName);
                roleManager.Create(saleRole);
            }
            #endregion
        }
    }
}